import 'package:base_plugin/base_plugin.dart';
import 'package:dio/dio.dart';

/// 员工联系人
class HttpEmployeeContactService {
  /// 联系人列表
  static Future<Response> contactList([String type]) {
    return BaseConfig.httpBase.get('/api/employees', {'type': type});
  }

  /// 创建联系人
  static Future<Response> createContact(String name) {
    return BaseConfig.httpBase.postJson('/api/employees', {'name': name});
  }

  /// 创建联系人
  static Future<Response> createEmployee({
    String name,
    String title,
    String nationality,
    String race,
    String martial_status,
    String pass_type,
    String pr_started_at,
    String gender,
    String dob,
    String identity_number,
    String employee_number,
    String employment_type,
    String salary_period,
    String contribution,
    double contribution_amount,
    List income_data,
    List deduction_data,
    List leave_data,
    num working_days_count,
    List working_days,
    String worker_levy,
    String joined_at,
    String confirmed_at,
    String country_code,
    String phone_number,
    String email,
    int is_director,
    String address_country,
    String address_city,
    String address_postal_code,
    String address_line_1,
    String address_line_2,
    String address_unit,
    String emergency_contact_name,
    String emergency_contact_relationship,
    String emergency_contact_phone_number,
    String emergency_contact_country_code,
    String bank_account_name,
    String bank_account_number,
    String bank_name,
    String bank_code,
    String bank_branch_code,
    String identity_issued_at,
    String identity_expire_at,
  }) {
    return BaseConfig.httpBase.postJson('/api/employees', {
      "name": name,
      'identity_issued_at': identity_issued_at,
      'identity_expire_at': identity_expire_at,
      "title": title,
      "nationality": nationality,
      "race": race,
      "martial_status": martial_status,
      "pass_type": pass_type,
      "pr_started_at": pr_started_at,
      "gender": gender,
      "dob": dob,
      "identity_number": identity_number,
      "employee_number": employee_number,
      "employment_type": employment_type,
      "salary_period": salary_period,
      "contribution": contribution,
      "contribution_amount": contribution_amount,
      "income_data": income_data,
      "deduction_data": deduction_data,
      "leave_data": leave_data,
      "working_days_count": working_days_count,
      "working_days": working_days,
      "worker_levy": worker_levy,
      "joined_at": joined_at,
      "confirmed_at": confirmed_at,
      "country_code": country_code,
      "phone_number": phone_number,
      "email": email,
      "is_director": is_director,
      "address_country": address_country,
      "address_city": address_city,
      "address_postal_code": address_postal_code,
      "address_line_1": address_line_1,
      "address_line_2": address_line_2,
      "address_unit": address_unit,
      "emergency_contact_name": emergency_contact_name,
      "emergency_contact_relationship": emergency_contact_relationship,
      "emergency_contact_country_code": emergency_contact_country_code,
      "emergency_contact_phone_number": emergency_contact_phone_number,
      "bank_account_name": bank_account_name,
      "bank_account_number": bank_account_number,
      "bank_name": bank_name,
      "bank_code": bank_code,
      "bank_branch_code": bank_branch_code
    });
  }

  /// 显示联系人
  static Future<Response> showContact(int id) {
    return BaseConfig.httpBase.get('/api/employees/$id', {});
  }

  /// 更新联系人
  static Future<Response> updateContact(
    int contactId, {
    String name,
    String title,
    String nationality,
    String race,
    String martial_status,
    String pass_type,
    String pr_started_at,
    String gender,
    String dob,
    String identity_number,
    String employee_number,
    String employment_type,
    String salary_period,
    String contribution,
    double contribution_amount,
    List income_data,
    List deduction_data,
    List leave_data,
    num working_days_count,
    List working_days,
    String worker_levy,
    String joined_at,
    String confirmed_at,
    String country_code,
    String phone_number,
    String email,
    int is_director,
    String address_country,
    String address_city,
    String address_postal_code,
    String address_line_1,
    String address_line_2,
    String address_unit,
    String emergency_contact_name,
    String emergency_contact_relationship,
    String emergency_contact_phone_number,
    String emergency_contact_country_code,
    String bank_account_name,
    String bank_account_number,
    String bank_name,
    String bank_code,
    String bank_branch_code,
    String identity_issued_at,
    String identity_expire_at,
  }) {
    return BaseConfig.httpBase.putJson('/api/employees/$contactId', {
      "name": name,
      'identity_issued_at': identity_issued_at,
      'identity_expire_at': identity_expire_at,
      "title": title,
      "nationality": nationality,
      "race": race,
      "martial_status": martial_status,
      "pass_type": pass_type,
      "pr_started_at": pr_started_at,
      "gender": gender,
      "dob": dob,
      "identity_number": identity_number,
      "employee_number": employee_number,
      "employment_type": employment_type,
      "salary_period": salary_period,
      "contribution": contribution,
      "contribution_amount": contribution_amount,
      "income_data": income_data,
      "deduction_data": deduction_data,
      "leave_data": leave_data,
      "working_days_count": working_days_count,
      "working_days": working_days,
      "worker_levy": worker_levy,
      "joined_at": joined_at,
      "confirmed_at": confirmed_at,
      "country_code": country_code,
      "phone_number": phone_number,
      "email": email,
      "is_director": is_director,
      "address_country": address_country,
      "address_city": address_city,
      "address_postal_code": address_postal_code,
      "address_line_1": address_line_1,
      "address_line_2": address_line_2,
      "address_unit": address_unit,
      "emergency_contact_name": emergency_contact_name,
      "emergency_contact_relationship": emergency_contact_relationship,
      "emergency_contact_country_code": emergency_contact_country_code,
      "emergency_contact_phone_number": emergency_contact_phone_number,
      "bank_account_name": bank_account_name,
      "bank_account_number": bank_account_number,
      "bank_name": bank_name,
      "bank_code": bank_code,
      "bank_branch_code": bank_branch_code
    });
  }

  /// 删除联系人
  static Future<Response> deleteContact(int contactId) {
    return BaseConfig.httpBase.deleteJson('/api/employees/$contactId', {});
  }

  /// 离职
  static Future<Response> resignContact(int contactId, String dateTime) {
    return BaseConfig.httpBase
        .postJson('/api/employees/$contactId/resign', {'date': dateTime});
  }

  static Future<Response> showDots() {
    return BaseConfig.httpBase.get('/api/employees/dots', {});
  }
}
